extends "../i_TD_core/i_TD_core.gd"




func init():
	.init()
	name = "血量核心"
	resetdata()
	info = info + "核心护盾：当血量低于30%时，免疫本次伤害并生成持续3s，值为20%血量上限的护盾[cd:8s]\n" 

func _connect():
	._connect()
	masCha.connect("onHurt",self,"run")
#核心护盾
func run(atkinfo):
	if atkinfo.isMiss || !atkinfo.hurtVal:return
	if masCha.att.hp / masCha.att.maxHp < 0.3 && !flag1:
		flag1 = 1
		atkinfo.hurtVal = 0
		masCha.addBuff(HXHD.new(1))

#时间加速
func _upS():
	._upS()
	if flag1:return
	cnt2 += 1
	if cnt2 == 8:
		cnt2 = 0
		flag1 = 0

class HXHD:
	extends Buff
	var exs = 0
	var s = 0
	func _init(lv):
		attInit()
		life = 3
		id = "HXHD"

	func _connect():
		._connect()
		s = masCha.att.maxHp * 0.2
		exs = masCha.shield
		masCha.connect("onHurt",self,"run")
		masCha.changeShield(s)

	func _del():
		if s:
			masCha.changeShield(-s)

	func run(atkinfo):
		if exs:
			exs -= atkinfo.hurtVal
			if exs < 0:
				s += exs
				exs = 0
				if s < 0:
					s = 0
					isDel = true
		else:
			s -= atkinfo.hurtVal
			if s < 0:
				s = 0
				isDel = true